import type { RouteRecordRaw, RouteMeta } from 'vue-router';
// import { RoleEnum } from '/@/enums/roleEnum';
import { defineComponent } from 'vue';

export type Component<T extends any = any> =
    | ReturnType<typeof defineComponent>
    | (() => Promise<typeof import('*.vue')>)
    | (() => Promise<T>);

// 3.5 版本之后，TypeScript 在 lib.es5.d.ts 里添加了一个 Omit<T, K> 帮助类型。Omit<T, K> 类型让我们可以从另一个对象类型中剔除某些属性，并创建一个新的对象类型：
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta' | 'children'> {
    name: string;
    meta: RouteMeta;
    component?: Component | string;
    components?: Component;
    children?: AppRouteRecordRaw[];
    props?: Record<string, any>;
    fullPath?: string;
}

export interface MenuTag {
    type?: 'primary' | 'error' | 'warn' | 'success';
    content?: string;
    dot?: boolean;
}

export interface Menu {
    name: string;

    icon?: string;

    path: string;

    // path contains param, auto assignment.
    paramPath?: string;

    disabled?: boolean;

    children?: Menu[];

    orderNo?: number;

    // roles?: RoleEnum[];

    meta?: Partial<RouteMeta>;

    tag?: MenuTag;

    hideMenu?: boolean;
}

export interface MenuModule {
    orderNo?: number;
    menu: Menu;
}

// export type AppRouteModule = RouteModule | AppRouteRecordRaw;
export type AppRouteModule = AppRouteRecordRaw;
